package com.apes.framework.plugin.esb.processor.jpa;

import com.apes.framework.plugin.esb.api.Request;
import com.apes.framework.plugin.esb.processor.AbstractChainProcessor;
import com.apes.framework.plugin.esb.processor.Processor;
import com.apes.framework.util.ReflectUtil;
import lombok.Data;

/**
 * 功能：JPA查询权限
 *
 * @author xul
 * @create 2018-07-11 9:56
 */
@Data
public class AuthProcessor<T extends Request, R> extends AbstractChainProcessor<T, R> {
    private String field;  //字段
    private String operator = "in"; //操作
    private String purpose;  //所属、操作、查询、......
    private String type;  //公司、部门、仓库、网点、......
    private boolean nativeQuery = false;
    private String exp;

    @Override
    protected R doProcess(T source) {
        Processor processor;
        if (nativeQuery) {
            processor = new NativeAuthProcessor();
        } else {
            processor = new JpaAuthProcessor();
        }
        ReflectUtil.copyAll(this, processor);
        return (R) processor.process(source);
    }
}
